/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package it.allerj.gui.component;

import java.awt.Component;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author Alessandro Veracchi
 */
public class JComponentCellRenderer implements TableCellRenderer {

  public Component getTableCellRendererComponent(JTable table, Object value,
						 boolean isSelected,
						 boolean hasFocus,
						 int row, int column)
  {
    if(value instanceof JComponent){
      ((JComponent)value).setFocusable(false);
      ((JComponent)value).setOpaque(false);
      if(value instanceof JButton){
          ((JButton)value).setRolloverEnabled(false);
      }
      return (JComponent)value;
    }
    Component component = table.getCellRenderer(row, column).getTableCellRendererComponent(
	   table, value, isSelected, hasFocus, row, column);
    return component;
  }

}
